import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JmfTest extends JFrame {
	Player _player;

	JmfTest() {
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				_player.stop();
				_player.deallocate();
				_player.close();
				System.exit(0);
			}
		});
		// setExtent( 0, 0, 320, 260 );
		JPanel panel = (JPanel) getContentPane();
		panel.setLayout(new BorderLayout());
		String mediaFile = "vfw://0";
		try {
			MediaLocator mlr = new MediaLocator(mediaFile);
			_player = Manager.createRealizedPlayer(mlr);
			if (_player.getVisualComponent() != null)
				panel.add("Center", _player.getVisualComponent());
			if (_player.getControlPanelComponent() != null)
				panel.add("South", _player.getControlPanelComponent());
		} catch (Exception e) {
			System.err.println("Got exception " + e);
		}
	}

	public static void main(String[] args) {
		JmfTest jmfTest = new JmfTest();
		jmfTest.show();
	}
}